<div class="widget">
    <h3 style="text-align: left">Tìm kiếm tour du lịch</h3>
    <script language="javascript" src="<?php echo $this->baseUrl('application/js/jquery-1.8.3.js'); ?>"></script>
    <script language="javascript" src="<?php echo $this->baseUrl('application/js/jquery-ui.js'); ?>"></script>
    <script>
    $(function() {
        $( "#datepicker3" ).datepicker({
            dateFormat:"dd/mm/yy",
        });
    });
    </script>
    <?php
    //tao doi tuong cua place model
    $place_model=new Admin_Model_Place();
    $place = new Default_Model_Place();
    $list_place=$place->listPlace();
    ?>
    <div class="register_content">
        <form action="" method="get">
        <div style="float: left; margin-top: 4px;">
            Nơi khởi hành
            <!-- List theo danh sach diem den trong place -->
            <select name="start_place">
            <?php 
                foreach($list_place as $value) :
    				$levelCss = '';
    	            if($value['level'] == 0){
    	            	$name = $value['place_name'];
    	            }else if($value['level'] == 1){
    	            	$name = ' + ' . $value['place_name'];
    	            }else{
    	            	$name = ' - - ' . $value['place_name'];
    	            	$levelCss =  'padding-left: ' . (10 * $value['level']) . 'px;';
    	            }
            ?>
			<option value="<?php echo $value['place_id']; ?>" style="<?php echo $levelCss; ?>"><?php echo $name; ?></option>
			<?php endforeach; ?>
            </select>
            &nbsp;&nbsp;&nbsp;&nbsp;
            
            Nơi đến
            <select name="finish_place">
            <?php 
                foreach($list_place as $value) :
    				$levelCss = '';
    	            if($value['level'] == 0){
    	            	$name = $value['place_name'];
    	            }else if($value['level'] == 1){
    	            	$name = ' + ' . $value['place_name'];
    	            }else{
    	            	$name = ' - - ' . $value['place_name'];
    	            	$levelCss =  'padding-left: ' . (10 * $value['level']) . 'px;';
    	            }
            ?>
			<option value="<?php echo $value['place_id']; ?>" style="<?php echo $levelCss; ?>"><?php echo $name; ?></option>
			<?php endforeach; ?>
            </select>
            
            &nbsp;&nbsp;&nbsp;&nbsp;
            Ngày đi
            
            <input type="text" name="start_date" id="datepicker3"/>
            
            &nbsp;&nbsp;&nbsp;&nbsp;
            Giá
            <select name="price">
                <option value="0">Dưới 2 triệu</option>
                <option value="1">2 đến 4 triệu</option>
                <option value="2">4 đến 6 triệu</option>
                <option value="3">6 đến 8 triệu</option>
                <option value="4">8 đến 10 triệu </option>
                <option value="5">10 đến 13 triệu</option>
                <option value="6">13 đến 16 triệu</option>
                <option value="7">16 đến 20 triệu</option>
                <option value="8">Trên 20 triệu</option>
            </select>
            
            
        </div>
        <input type="submit" name="search" value="Tìm kiếm" class="button" style="float: left; position: relative; margin-left: 20px;" />
        </form>
        <div style="clear: both;"></div>
    </div>
    
    <!-- List categories select from database -->
    <div class="list_category" style="text-align: left;">
        <ol>
            <?php
                $category = new Default_Model_Category();
                $listCategory = $category->listCategory();
                foreach($listCategory as $value) :
            ?>
            <dt><a href="<?php echo $this->baseUrl('tour/index?cat_id=') . $value['cat_id']; ?>"><?php echo $value['cat_name']; ?></a></dt>
            <?php endforeach; ?>
        </ol>
    </div>
    
    
    
    <div class="register_content">
        <table>
            <tr class="head_table_tour">
                <td class="td_table_tour" style="width: 310px;">Tên tour du lịch</td>
                <td class="td_table_tour" style="width: 155px;">Điểm bắt đầu</td>
                <td class="td_table_tour" style="width: 155px;">Điểm đến</td>
                <td class="td_table_tour" style="width: 120px; text-align: center;">Ngày đi</td>
                <td class="td_table_tour" style="width: 120px;">Ngày về</td>
                <td class="td_table_tour" style="width: 120px;" ></td>
                <td class="td_table_tour" style="width: 100px;"></td>
            </tr>
            
            <?php
            if(count($this->data > 0)) :
            foreach($this->data as $tour):
            ?>
            <tr style="height: 30px;">
                <td><a style="color: blue;" href="<?php  echo $this->baseUrl("tour/details?id=".$tour['tour_id']);?>"></a> <?php  echo $tour['tour_name']; ?></td>
                
            
                <td><?php echo $place_model->getPlaceNameById($tour['start_place']); ?></td>
                <td><?php echo $place_model->getPlaceNameById($tour['finish_place']); ?></td>
                <td><?php echo $tour['start_date']; ?></td>
                <td><?php echo $tour['finish_date'];?></td>
                <td><a href="<?php echo $this->baseUrl("tour/details?tour_id=".$tour['tour_id']); ?>">Xem Chi Tiết</a></td>
                <td><a href="<?php echo $this->baseUrl('tour/book?tour_id='.$tour['tour_id']) ?>">Đặt tour</a></td>
            </tr>
            
            <?php endforeach; ?>
            <?php else : ?>
                <tr style="height: 30px;">
                    <td colspan="8">Không tìm thấy tour du lịch nào</td>
                </tr>
            <?php endif; ?>
        </table>
    </div>
</div>
